/**
 * Created by IntelliJ IDEA.
 * User: Taras_Brzezinsky
 * Date: 7/8/11
 * Time: 11:05 PM
 * To change this template use File | Settings | File Templates.
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.Arrays;

public class Volleyball extends Thread {

    public Volleyball() {
        this.input = new BufferedReader(new InputStreamReader(System.in));
        this.output = new PrintWriter(System.out);
        this.setPriority(Thread.MAX_PRIORITY);
    }

    static class Edge implements Comparable<Edge>{
        int from;
        long cost;
        public Edge(int from, long cost){
            this.from = from;
            this.cost = cost;
        }

        public int compareTo(Edge o) {
            long difference = this.cost - o.cost;
            return difference < 0 ? -1 : difference > 0? 1 : this.from - o.from;
        }
    }

    static class Tax {
        int cost;
        int distance;
        public Tax(int distance, int cost) {
            this.cost = cost;
            this.distance = distance;
        }
    }


    public void run() {
        try {
            int n = nextInt(), m = nextInt();
            int x = nextInt() - 1, y = nextInt() - 1;
            int [][]initial = new int[n][n], graph = new int[n][n];
            long []d = new long [n];
            ArrayList<Edge>[] T = new ArrayList[n];
            for (int i = 0; i < n; ++i){
                Arrays.fill(initial[i], Integer.MAX_VALUE);
                Arrays.fill(graph[i], Integer.MAX_VALUE);
            }
            for (int i = 0; i < m; ++i){
                int from = nextInt() - 1, to = nextInt() - 1, cost = nextInt();
                initial[from][to] = Math.min(initial[from][to], cost);
                initial[to][from] = initial[from][to];
            }
            for (int i = 0; i < n; ++i){
                T[i] = new ArrayList<Edge>();
                for (int j = 0; j < n; ++j){
                    if (initial[i][j] != Integer.MAX_VALUE){
                        T[i].add(new Edge(j, initial[i][j]));
                    }
                }
            }

            for (int s = 0; s < n; ++s){
                Tax currentTax = new Tax(nextInt(), nextInt());
                Arrays.fill(d, Long.MAX_VALUE);
                PriorityQueue<Edge> q = new PriorityQueue<Edge>();
                d[s] = 0;
                q.offer(new Edge(s, 0));
                while (!q.isEmpty()){
                    Edge current = q.poll();
                    if (current.cost > d[current.from]){
                        continue;
                    }
                    for (Edge adj : T[current.from]) {
                        if ((d[current.from] + adj.cost < d[adj.from]) && (d[current.from] + adj.cost <= currentTax.distance)){
                            d[adj.from] = d[current.from] + adj.cost;
                            q.offer(new Edge(adj.from, d[adj.from]));
                        }
                    }
                }
                for (int i = 0; i < n; ++i){
                    graph[s][i] = (d[i] == Long.MAX_VALUE) ? Integer.MAX_VALUE : currentTax.cost;

                }
                graph[s][s] = 0;
            }
            Arrays.fill(d, Long.MAX_VALUE);
            boolean used[] = new boolean[n];
            d[x] = 0;
            for (int i = 0; i < n; ++i){
                int to = -1;
                for (int j = 0; j < n; ++j){
                    if (!used[j] && (to == -1 || d[j] < d[to])){
                        to = j;
                    }
                }
                if (d[to] == Long.MAX_VALUE){
                    break;
                }
                used[to] = true;
                for (int j  = 0; j < n; ++j){
                    if (graph[to][j] != Integer.MAX_VALUE){
                            d[j] = Math.min(d[j], d[to]  + graph[to][j]);
                    }
                }
            }
            output.println(d[y] == Long.MAX_VALUE ? -1 : d[y]);
            output.flush();
            output.close();

        } catch (Throwable e) {
            System.err.println(e.getMessage());
            System.err.println(Arrays.deepToString(e.getStackTrace()));
        }
    }


    public static void main(String[] args) {
        new Volleyball().start();
    }

    private String nextToken() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }


    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}
